layui.use(['form', 'admin', 'ax', 'upload'], function () {
    var $ = layui.jquery;
    var $ax = layui.ax;
    var form = layui.form;
    var admin = layui.admin;

    //获取详情信息，填充表单
    var ajax = new $ax(Changein.ctxPath + "/contactType/detail?id=" + Changein.getUrlParam("id"));
    var result = ajax.start();
    form.val('contactTypeForm', result.data);

    //表单提交事件
    var updateLock = false;
    form.on('submit(btnSubmit)', function (data) {
        if (!updateLock) {
            updateLock = true;
            var ajax = new $ax(Changein.ctxPath + "/contactType/editItem", function (data) {
                updateLock = false;
                if (data.code == 200) {
                    Changein.success("更新成功！");
                    //传给上个页面，刷新table用
                    admin.putTempData('formOk', true);
                    //关掉对话框
                    admin.closeThisDialog();
                } else {
                    Changein.error("更新失败！" + data.message)
                }
            }, function (data) {
                updateLock = false;
                Changein.error("更新失败！" + data.responseJSON.message)
            });
            ajax.set(data.field);
            ajax.start();
            return false;
        }
    });

});